package com.Yourweibo.util;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;

import com.Yourweibo.R;
 

public class HttpLoadAsync {

	private Context context;
	private String progressDialogMessage;
	private ProgressDialog progressdialog;
	private Intent intent;
	public interface HttpCallBack{
		public Intent Loading();
		
		
	};
	private Handler handler=new Handler(){

		@Override
		public void handleMessage(Message msg) {
			// TODO Auto-generated method stub
			super.handleMessage(msg);
			progressdialog.dismiss();
			context.startActivity(intent);
					}
		
		
	};
    public  HttpLoadAsync(Context context,String progressDialogMessage){
    	this.context=context; 
    	this.progressDialogMessage=progressDialogMessage;
    	 
     }
    public void execute(final HttpCallBack callback){
    	progressdialog=ProgressDialog.show(context,context.getString(R.string.loading_dialog_title) ,progressDialogMessage,true);
 
    	new Thread(){

			@Override
			public void run() {
				// TODO Auto-generated method stub
				super.run();
				intent=callback.Loading();
				Message msg=handler.obtainMessage();
				handler.sendMessage(msg);
			}
    
    	}.start();
					
		 
 
    	
    	
    }

}
